<template>
	<view>
		<swiperComponent></swiperComponent>
		<view class="time-type-sel">
			<uni-data-select class="time-sel" v-model="time" :localdata="timeList" />
			<uni-data-select class="type-sel" v-model="type" :localdata="typeList" />
			<button class="submit" type="primary" @click="submit">确认提交</button>
		</view>
		<view class="fatebox" v-if="horoscope.time">
			<p class="title">{{horoscope.type}}</p>
			<p class="title">星座：{{horoscope.title}}</p>
			<p class="title">幸运星座：{{horoscope.luckyconstellation}}</p>
			<p class="title">幸运色：{{horoscope.luckycolor}}</p>
			<p class="title">幸运数：{{horoscope.luckynumber}}</p>
			<p class="title">今日忌：{{horoscope.todo.ji}}</p>
			<p class="title">今日宜：{{horoscope.todo.yi}}</p>
			<p class="title">简短评论：{{horoscope.shortcomment}}</p>
			<p class="title">算命书：{{horoscope.fortunetext.all}}</p>
			<p class="title">健康值：{{horoscope.index.health}}</p>
			<p class="title">健康：{{horoscope.fortunetext.health}}</p>
			<p class="title">爱情值：{{horoscope.index.love}}</p>
			<p class="title">爱情：{{horoscope.fortunetext.love}}</p>
			<p class="title">经济值：{{horoscope.index.money}}</p>
			<p class="title">经济：{{horoscope.fortunetext.money}}</p>
			<p class="title">事业值：{{horoscope.index.work}}</p>
			<p class="title">事业：{{horoscope.fortunetext.work}}</p>
		</view>
	</view>
</template>
<script>
	import swiperComponent from '../components/swiper-component/swiper-component';
	import { getFate } from '@/config/api_config.js';
	export default {
		components: {
			swiperComponent
		},
		data() {
			return {
				time:'',
				timeList: [
					{value:'today',text:'今日'},
					{value:'nextday',text:'明日'},
					{value:'week',text:'一周'},
					{value:'month',text:'一月'}
				],
				type: '',
				typeList:[
					{value:'aries',text:'白羊座'},{value:'taurus',text:'金牛座'},{value:'gemini',text:'双子座'},{value:'cancer',text:'巨蟹座'},
					{value:'leo',text:'狮子座'},{value:'virgo',text:'处女座'},{value:'libra',text:'天秤座'},{value:'scorpio',text:'天蝎座'},
					{value:'sagittarius',text:'射手座'},{value:'capricorn',text:'摩羯座'},{value:'aquarius',text:'水瓶座'},{value:'pisces',text:'双鱼座'},
				],
				horoscope: {
					todo:{ji:''},
					fortunetext:{all:''},
					index:{health:''}
				}
			}
		},
		methods: {
			// 获取星座运势
			async submit() {
				const res = await getFate(this.time, this.type);
				this.horoscope = res.data;
				if (!this.time || !this.type) {
					uni.showToast({
						title: '请选择',
						icon: 'none'
					})
				}
			}
		}
	}
</script>


<style>
	@import url('../css/homes.css');
</style>